package entity

import (
	"encoding/json"
	"github.com/gin-gonic/gin"
)

type User struct {
	Id        int    `json:"id"`
	Username  string `json:"username"`
	Password  string `json:"password"`
	Type      string `json:"type"`
	Email     string `json:"email"`
	IsCommend bool   `json:"isCommend"`
	// 用户当前是否是登录状态
	IsAuth bool `gorm:"-"`
	// type数组
	TypeList []int `gorm:"-"`
}

func (User) TableName() string {
	return "user"
}

// 请求体中获取 User 对象
func GetUser(c *gin.Context) User {
	data, _ := c.GetRawData()
	var u User
	_ = json.Unmarshal(data, &u)
	return u
}
